/* eslint-disable */
import JSEncrypt from 'jsencrypt'
import Encrypt from 'encryptlong'

const publicKey = 'MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJWQNmPi+kr1/GX/VWsooY9o7t+KD0vqdo3QALx5RMufV1yLoIevM48nVpJtdKhyx4CPvZp3nJtXms1GgJ2VifEobWAKiLmC+RW3dUjutMbfijV5VZUpwRBVENGXRnJ9vadEddrk1iaXKwQoZ3Z/J3gFTIWaVgX+kkSRvW1LfkcpAgMBAAECgYAIvbg0D8q1kVlaQ7lEDUid91HIrkq1EuOxZ5f3a/X9mZczQTTVYUO36OJqJewEwUqQJLZ93eJBAPZ661UugJQidWVw0xujbUpuCDtVaXEqRwrIlyE8qpQFKqyk4jxhHdPqiQwu1nM2hZQUBNTKAFnQG0co20cTsgd1iPlSMCw4NQJBAM4dMNpF7TrnUkvTshV/0ci7nwroUuyIq0T1C5J3aMKX/xdGFTKNNmamCYkvimbu+k39JIqBTqYbgOkFZoKG0jUCQQC5wyUThhVJzMzRHU97cm6iRhDDsCirfOK8V3zoZwReyzP74VSq0AQ0Sf1I5TkyneJ7hhvwxe4xxaTEt1jpHv+lAkA7sGJsY6G+1CyV/vlslnaHPiZhv0P8cdu/fYNbaC8zY1chQ09yM0jU0zKhwt2+z2g3W57QaYAARKjBUqoMFMUdAkEAnjsricXcvFBG5pkg6vY+ZttnzEhxXCG0wNmE/DFD97r/PL5jcFxgOGoN5dnbLtJt6OoDQsRWcO75utayVWCiQQJAcPWD8yvC1S4y9ZdtdKpZijatSxDgsDiJdKTt8M4p/11e3TrD+YkXFYPSX4DppGxCQUiZwXASSVtN6wI6EKAIQQ=='
const privateKey = 'MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJWQNmPi+kr1/GX/VWsooY9o7t+KD0vqdo3QALx5RMufV1yLoIevM48nVpJtdKhyx4CPvZp3nJtXms1GgJ2VifEobWAKiLmC+RW3dUjutMbfijV5VZUpwRBVENGXRnJ9vadEddrk1iaXKwQoZ3Z/J3gFTIWaVgX+kkSRvW1LfkcpAgMBAAECgYAIvbg0D8q1kVlaQ7lEDUid91HIrkq1EuOxZ5f3a/X9mZczQTTVYUO36OJqJewEwUqQJLZ93eJBAPZ661UugJQidWVw0xujbUpuCDtVaXEqRwrIlyE8qpQFKqyk4jxhHdPqiQwu1nM2hZQUBNTKAFnQG0co20cTsgd1iPlSMCw4NQJBAM4dMNpF7TrnUkvTshV/0ci7nwroUuyIq0T1C5J3aMKX/xdGFTKNNmamCYkvimbu+k39JIqBTqYbgOkFZoKG0jUCQQC5wyUThhVJzMzRHU97cm6iRhDDsCirfOK8V3zoZwReyzP74VSq0AQ0Sf1I5TkyneJ7hhvwxe4xxaTEt1jpHv+lAkA7sGJsY6G+1CyV/vlslnaHPiZhv0P8cdu/fYNbaC8zY1chQ09yM0jU0zKhwt2+z2g3W57QaYAARKjBUqoMFMUdAkEAnjsricXcvFBG5pkg6vY+ZttnzEhxXCG0wNmE/DFD97r/PL5jcFxgOGoN5dnbLtJt6OoDQsRWcO75utayVWCiQQJAcPWD8yvC1S4y9ZdtdKpZijatSxDgsDiJdKTt8M4p/11e3TrD+YkXFYPSX4DppGxCQUiZwXASSVtN6wI6EKAIQQ=='

export function rsaPublicDate (data, key) {
  const jsencrypt = new JSEncrypt()
  jsencrypt.setPublicKey(key || publicKey)
  return jsencrypt.encrypt(data)
}

export function rsaPrivateDate (data, key) {
  const jsencrypt = new JSEncrypt()
  jsencrypt.setPrivateKey(key || privateKey)
  return jsencrypt.encrypt(data)
}

export function encrypt (data, key) {
  const encryptor = new Encrypt()
  encryptor.setPublicKey(key || publicKey)
  return encryptor.encryptLong(data)
}

export function decrypt (data, key) {
  const encryptor = new Encrypt()
  encryptor.setPrivateKey(key || privateKey)
  return encryptor.decryptLong(data)
}